const app = getApp()
var c = require("../common.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    imgUrls: [
      {
        id: 1,
        link: '/pages/index/index',
        url: 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg'
      }, {
        id: 2,
        link: '/pages/logs/logs',
        url: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg'
      }, {
        id: 3,
        link: '/pages/test/test',
        url: 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
      }
    ],

    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000
  },
  //轮播图点击事件
  imgclick: function (e) {
    console.log(e);
  },

  


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //加载新闻咨询
    var sql = 'o(news_id=asc)l(10)fs(description|5)date(create_time|Y-m-d H:i)';
    c.ajax(
      app.dbs +'news_article',
    { sql: sql},

      res => {
        console.log(res.data);
        this.setData({
          news: res.data
        })
      }
    )
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },
  moreinfo:function(){
   var newsold = this.data.news;
   var page= this.data.page;
   var pagenum = page*10;
   this.setData({page:page+1});
    var sql = 'o(news_id=asc)l(' + pagenum +',10)fs(description|5)date(create_time|Y-m-d)';
    c.ajax(
      app.dbs +'news_article',
      { sql: sql},
      res => {
        console.log(res.data);
        this.setData({
          news: newsold.concat(res.data)
        })
      }
    )
  }
})